<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <title>新增账号</title>
    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta name="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <link rel="stylesheet" href="/css/formSelects-v4.css"/>
</head>
<body style="padding: 10px;background: white;min-height: 90%">
<div id="divvuehtml" style="width: 90%;height: 100%;margin: auto;">
    <form class="layui-form" id="add">
        <table class="layui-table" lay-size="sm">
            <thead>
                <tr>
                    <th colspan="4" style="text-align: center;">新增教师</th>
                </tr>
            </thead>
            <tbody style="text-align: center;">
            <tr>
                <td>编号</td>
                <td colspan="3">
                    <input type="text" name="no"  required lay-verify="required" lay-verType="tips"  lay-reqText="编号不能为空" placeholder="请输入编号"  autocomplete="off" class="layui-input">
                </td>
            </tr>
            <tr>
                <td>姓名</td>
                <td colspan="3">
                    <input type="text" name="name" required lay-verify="required" lay-reqText="姓名不能为空"  placeholder="请输入姓名"  autocomplete="off" class="layui-input">
                </td>
            </tr>
            <tr>
                <td>性别</td>
                <td colspan="3">
                    <select name="sex" required lay-verify="required">
                        <option value="男">男</option>
                        <option value="女">女</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>年龄</td>
                <td colspan="3">
                    <input type="text" name="age" required lay-verify="required|number" lay-reqText="年龄不能为空"  placeholder="请输入年龄"  autocomplete="off" class="layui-input">
                </td>
            </tr>
            <tr>
                <td>所在系部</td>
                <td colspan="3">
                    <input type="text" name="xibu"  required lay-verify="required" lay-reqText="所在系部不能为空"  placeholder="请输入所在系部"  autocomplete="off" class="layui-input">
                </td>
            </tr>
            <tr>
                <td>专业</td>
                <td colspan="3">
                    <input type="text" name="zhuanye"  required lay-verify="required" lay-reqText="专业不能为空"  placeholder="请输入专业"  autocomplete="off" class="layui-input">
                </td>
            </tr>
            <tr>
                <td>职称</td>
                <td colspan="3">
                    <input type="text" name="zhichen"  required lay-verify="required" lay-reqText="职称不能为空"  placeholder="请输入职称"  autocomplete="off" class="layui-input">
                </td>
            </tr>
            <tr >
                <td colspan="4">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">新增</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
</body>
<script src="/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/xadmin.js"></script>
<script type="text/javascript" src="/js/vue.js"></script>
<script th:inline="none">
    setTimeout(function(){
        layui.config({
            base: '/js/' //此处路径请自行处理, 可以使用绝对路径
        }).extend({formSelects: 'formSelects-v4'}).use(['table','form','layer','formSelects','laydate'],function() {
            var form = layui.form;
            var layer = layui.layer;
            var laydate = layui.laydate;
            //执行一个laydate实例
            laydate.render({
                elem: '#rzdate', //指定元素
            });
            //监听提交
            form.on('submit(formDemo)', function(data){
                var index;
                $.ajax({
                    url : "/api/admin/jiaoshi/insert",
                    type : "POST",
                    data : data.field,
                    dataType : "json",
                    beforeSend : function(XMLHttpRequest) {
                        index = layer.msg('正在提交数据中，请稍候', {
                            icon : 16,
                            time : false,
                            shade : 0.8
                        });
                    },success : function(data) {
                        if(data.success){
                            // 刷新父页面
                            layer.alert(data.msg, {
                                icon : 6
                            }, function() {
                                xadmin.close();
                                // 刷新父页面
                                parent.location.reload();
                            });
                        }else{
                            xadmin.alert(data.msg,2)
                        }
                    },complete : function(XMLHttpRequest, textStatus) {
                        layer.close(index);
                    },error : function(data) {
                        layer.alert('网络异常或者数据错误', {
                            icon : 2
                        });
                    }
                });
                return false;
            });
        });
    }, 300);
</script>
</html>
